//
//  WBVisitorTableViewController.swift
//  weibo
//
//  Created by 胡古古 on 2017/6/5.
//  Copyright © 2017年 hugugu. All rights reserved.
//

import UIKit

class WBVisitorTableViewController: UITableViewController,WBVisitorViewDelegate {
    
    var isLogin: Bool = WBUserAccountViewModel.sharedViewModel.isLogin
    
    var visitorView: WBVisitorView?

    override func loadView() {
        
        if isLogin {
            
            super.loadView()
            
        } else {
          
            setupNavUI()
            
            visitorView = WBVisitorView()
            
            visitorView?.delegate = self
            
            visitorView?.backgroundColor = UIColor(white: 237 / 255, alpha: 1)
            
            view = visitorView
            
        }

    }

    override func viewDidLoad() {
        super.viewDidLoad()
      
        
    }

    private func setupNavUI() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(target: self, action: #selector(clickLeftButton), title: "注册")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(target: self, action: #selector(clickRightButton), title: "登录")
    }
    
    @objc private func clickLeftButton() {
        
        entuerOAuthVC()
        
    }
    
    @objc private func clickRightButton()  {
        
        entuerOAuthVC()
    }
    
    // 代理的回调
    func loginOperation() {
        
        entuerOAuthVC()
        
    }
    
    private func entuerOAuthVC() {
        
        let oauthVC = WBOAuthViewController()
        let nav = WBNavigationViewController(rootViewController: oauthVC)
        self.present(nav, animated: true, completion: nil)
        
    }


    
}

